﻿namespace LiveLabs.Logging
{
    using System;
    using Xunit;

    public class LoggerConstructorFixture
    {
        [Fact]
        public void Should_Throw_In_Constructor_With_Null_Name()
        {
            string name = null;
            ArgumentNullException ex 
                = Assert.Throws<ArgumentNullException>(() => new Logger(name));
            Assert.Equal("name", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Empty_Name()
        {
            string name = string.Empty;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name));
            Assert.Equal("name", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Null_Type()
        {
            Type type = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(type));
            Assert.Equal("type", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Null_Name_And_Null_Log()
        {
            string name = null;
            Log log = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, log));
            Assert.Equal("name", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Empty_Name_And_Null_Log()
        {
            string name = string.Empty;
            Log log = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, log));
            Assert.Equal("name", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Name_And_Null_Log()
        {
            string name = "a.b.c";
            Log log = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, log));
            Assert.Equal("log", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Null_Type_And_Null_Log()
        {
            Type type = null;
            Log log = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(type, log));
            Assert.Equal("type", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Type_And_Null_Log()
        {
            Type type = typeof(Foo<DateTime, TimeSpan>.Inner);
            Log log = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(type, log));
            Assert.Equal("log", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Null_Name_And_Null_Settings()
        {
            string name = null;
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, set));
            Assert.Equal("name", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Empty_Name_And_Null_Settings()
        {
            string name = string.Empty;
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, set));
            Assert.Equal("name", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Name_And_Null_Settings()
        {
            string name = "a.b.c";
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, set));
            Assert.Equal("settings", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Null_Type_And_Null_Settings()
        {
            Type type = null;
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(type, set));
            Assert.Equal("type", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Type_And_Null_Settings()
        {
            Type type = typeof(Foo<DateTime, TimeSpan>.Inner);
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(type, set));
            Assert.Equal("settings", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Null_Name_And_Null_Log_And_Null_Settings()
        {
            string name = null;
            Log log = null;
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, log, set));
            Assert.Equal("name", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Empty_Name_And_Null_Log_And_Null_Settings()
        {
            string name = string.Empty;
            Log log = null;
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, log, set));
            Assert.Equal("name", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Name_And_Null_Log_And_Null_Settings()
        {
            string name = "a.b.c";
            Log log = null;
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, log, set));
            Assert.Equal("log", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Name_And_Log_And_Null_Settings()
        {
            string name = "a.b.c";
            Log log = new TestLog();
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(name, log, set));
            Assert.Equal("settings", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Null_Type_And_Null_Log_And_Null_Settings()
        {
            Type type = null;
            Log log = null;
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(type, log, set));
            Assert.Equal("type", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Type_And_Null_Log_And_Null_Settings()
        {
            Type type = typeof(Foo<DateTime, TimeSpan>.Inner);
            Log log = null;
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(type, log, set));
            Assert.Equal("log", ex.ParamName);
        }

        [Fact]
        public void Should_Throw_In_Constructor_With_Type_And_Log_And_Null_Settings()
        {
            Type type = typeof(Foo<DateTime, TimeSpan>.Inner);
            Log log = new TestLog();
            Settings set = null;
            ArgumentNullException ex
                = Assert.Throws<ArgumentNullException>(() => new Logger(type, log, set));
            Assert.Equal("settings", ex.ParamName);
        }
    }
}
